<?php
/*
<Model Information> 
Author: Naseer Ahmad
Date: 13-10-2011
Last Updated on:
*/

class adminChangePasswordModel extends appModel
{
	var $name = 'adminChangePasswordModel';
	
	
	function changePassword($currentPass, $pass1, $pass2)
	{
		v('Your Password', $pass1, 'password', $pass2);
		
		if(!isset($_SESSION[v]))
		{
			$cp = md5($currentPass);
			$res = $this -> _getSingleData('usersInfo', 'userPassword', 
						"userID = ".$_COOKIE['adminid_gosell']);

			if($res==$cp)
			{
				$arrData = array("userPassword" => md5($pass1));
				$arrWhere = array("userID" => $_COOKIE['adminid_gosell']);
				
				if($this -> _updateTable('usersInfo', $arrData,
										$arrWhere))
				{
					return 'ok';
				}
				else
				{
					return 'Error in DB '.$this -> getError();
				}
													
			}
			else
			{
				return 'Current Password Not Valid';
			}
						
		}
		else
		{
			return $_SESSION['v'];
		}
	}
}

?>